package com.znsd.zl.app.reservation.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.znsd.zl.app.reservation.dao.IReservationDao;
import com.znsd.zl.app.reservation.entity.ReservationEntity;
import com.znsd.zl.app.reservation.service.IReservationService;
import com.znsd.zl.app.reservation.vo.req.ReservationEntityVO;
import com.znsd.zl.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName ReservationServiceImpl
 * @Description 预约管理service层实现类
 * @author jbb
 * @email jbb@163.com
 * @date 2020-08-21 21:13:34
 * @Version v1.0
 */
@Service("tReservationService")
public class ReservationServiceImpl extends ServiceImpl<IReservationDao, ReservationEntity> implements IReservationService {


    @Override
    public PageUtils queryPage(Map<String, Object> params, Integer page, Integer limit) {
        params.remove("t");
        System.out.println(params);
        List<ReservationEntityVO> list = getBaseMapper().queryPage(params,page==null?0:(page-1)*limit,limit==null?10:limit);
        System.out.println(list);
        IPage p=new Page();
        p.setRecords(list);
        p.setCurrent(page);
        p.setTotal(getBaseMapper().queryPageCount(params));
        return new PageUtils(p);
    }

    @Override
    public Integer getPending(String userId) {
        return getBaseMapper().getPending(userId);
    }

    @Override
    public Integer selectUpdate(Map map, Object id) {
        map.remove("t");
        getBaseMapper().selectUpdate(map, id);
        return null;
    }

    @Override
    public ReservationEntity isReservation(Integer userId, Integer houseId) {
        return getBaseMapper().isReservation(userId, houseId);
    }
}
